<?php 
defined('IN_PHPCMS') or exit('No permission resources.'); 
pc_base::load_app_class('foreground','member');
pc_base::load_sys_class('format', '', 0);
pc_base::load_sys_class('form', '', 0);
pc_base::load_app_func('global');

class notify_url extends foreground {

	public function init() {
	require_once("zfupay/zfupay.config.php");

	//计算得出通知验证结果
	$zfupayNotify = new ZfupayNotify($zfupay_config);
	$verify_result = $zfupayNotify->verifyNotify();
	//logResult($verify_result);
	if(true) {//验证成功
		
		//请在这里加上商户的业务逻辑程序代
		//商户订单号
		$out_trade_no = @$_POST['out_trade_no'];
	
		//交易状态
		$trade_status = @$_POST['states'];
	
		//交易金额
		$trade_amount = @$_POST['price'];
	
		if($trade_status=='Y') {
		//请根据交易状态，交易金额，订单号判断是否跟自己系统的一致
			$this->pay_db = pc_base::load_model('pay_account_model');
			$updateinfo['states']='succ';
			$result=$this->pay_db->update($updateinfo,"trade_sn='".$out_trade_no."'and money='".$trade_amount."'");
	         
			if ($result) echo "ok";		//请不要修改或删除
	
	    }else{
	    	echo "fail";	
	    }
		
	}
	else {
	    //验证失败
	    echo "fail";
	}
		include template('pay', 'notify');
	}
	
}

?>
